
ros_cmd = "/opt/ros/%s/env.sh " % node[:'ros']['distribution']

directory node[:'ros']['ws-name'] + "/src"

execute 'Initialize a catkin workspace' do
    not_if 'test -e CMakeLists.txt'
    cwd node[:'ros']['ws-name'] + "/src"
    command ros_cmd + 'catkin_init_workspace'
end

execute 'catkin_make' do
    cwd node[:'ros']['ws-name']
    command ros_cmd + 'catkin_make'
end

execute 'Environment setup' do
    add_cmd = "source %s/devel/setup.bash" % node[:'ros']['ws-name']
    not_if 'grep "%s" ~/.bashrc' % add_cmd
    command 'echo "%s" >> ~/.bashrc' % add_cmd
end

